<template>
  <div>
    <el-row style="text-align: left;">
      <el-row>
      <span>
        订单编号: {{order.code}}
      </span>
      </el-row>
      <el-row>
      <span>
        应付金额: ¥{{(order.orderMoney/100).toFixed(2)}}
      </span>
      </el-row>
    </el-row>
    <el-row>
      <div
        @click="handlePay"
        style="border-radius: 2px; cursor: pointer;width: 120px;padding:5px;background-color:rgb(205,65,60);color:white;font-weight: bolder;font-size: 20px;">
        立即支付
      </div>
    </el-row>
  </div>
</template>

<script>
  import {mapState} from 'vuex'

  export default {
    name: "Payment",
    data() {
      return {
        order: {
          code: '',
          orderMoney: 0
        }
      }
    },

    computed: {
      ...mapState({
        orders: state => state.auth.orders
      })
    },


    created() {
      const id = this.$route.params.id;
      console.log("id===="+id);
      this.api.__api__OrdersOne(id)
        .then(data=>{
          this.order = data.data;
        }).catch(error=>null);
    },

    methods: {
      handlePay(){
        this.api.__api__OrdersStatusUpdate(this.order.code,1)
          .then(data=>{
            this.$router.push('/order').catch(error=>null);
          })
      }
    }
  }
</script>

<style scoped>

</style>
